/**
 * 参数列表
 */
var vo={};
$(function(){
	var openWindow=window.document;
	$("#paramList").height($(openWindow).height()-$(openWindow).height()*0.05-85);
	setInterval(function(){
		$("#paramList").width(window.parent.$("#centerIframe").width()-124)
	},1000)
	var date=new Date();
	$("#searchText").val("");
	
	 $("#paramList").datagrid({
			url:$Path+'/admin/param/getList',
			method:'GET',
			pagination:true,
			pageList: [30,50,200],
			loadMsg:'加载中......',
			fitColumns:true,
			sortName:"paramid",
			sortOrder:"desc",
			singleSelect:true,
			rowStyler:function(index,row){   
		        if (row.status==2){   
		        	return 'background-color:'+window.flagColor;
		        }   
		    }, 
			columns:[[
					 {field:'paramid',title:'参数名',sortable:true, align:'center',width:100},
			         {field:'paramvalue',title:'参数值', align:'center',width:100},
			         {field:'remark',title:'备注', align:'center',width:200},
			         {field:'id' ,align:'center',title:'操作',width:50,formatter: function(value, row, index){
						 var re=new RegExp("{param}","g");
						 var ref=opt.replace(re,row.paramid);
						 return ref;
			         }}
			     ]]
		});
		//如果操作项为空隐藏操作列
		if(opt==''){
			$("#paramList").datagrid('hideColumn','id');
		}
		//绑定顶部操作按钮
		$("#paramList").datagrid({
			toolbar: '#tb'
		});
		//绑定回车事件
		$(document).keydown(function(event){ 
			if(event.keyCode==13){
				window.event.returnValue=false;
			}
		});
})
/**
 * 查询
 */
function searchCase(){
	vo.searchText=$("#searchText").val();
	$("#paramList").datagrid('load',vo);
}
/**
 * 编辑
 */
function edit(paramid){
	window.parent.openDialog("编辑参数信息",'/admin/param/editParam','',550,400,'paramid='+paramid);
}
function reloadGrid(){
	$("#paramList").datagrid('reload',null);
}
/**
 * 同步更新缓存
 */
function sysCache(){
	var auth=window.parent.getAuth();
	parent.$.messager.confirm('同步参数','您确定要同步参数吗？',function(data){
		if(data){
			window.parent.showloading();
			$.ajax({
				type:'post',
				data:{authenticityToken:auth},
				url: $Path+'/admin/param/updateCache',
				success:function(data){
					window.parent.hideloading();
					if(data.code==200){
						parent.$.messager.alert("成功","同步成功",'info');
					}
					else{
						parent.$.messager.alert("重启失败",data.msg,'error');
					}
				},
				error:function(data){
					window.parent.hideloading();
					parent.$.messager.alert("重启失败","服务器开小差了~",'error');
				}
			});
		}
	})
}